package com.atguigu.redis;

import com.alibaba.nacos.client.utils.StringUtils;
import com.atguigu.constant.RedisConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class RedisMessageReceiver {
    @Autowired
    private RedisTemplate redisTemplate;

    public void receiceChannelMessage(String message){
        if(StringUtils.isNotEmpty(message)){
        message=message.replaceAll("\"","" );
        String[] splitMessage = message.split(":");
        if (splitMessage.length==2){
            redisTemplate.opsForValue().set(RedisConst.SECKILL_STATE_PREFIX+splitMessage[0],splitMessage[1]);
        }
    }
}
}




















